package com.example.smart.ui.activity.home

import com.example.lib.extend.setOnDoubleClickListener
import com.example.lib.utils.sp.SpUtils
import com.example.lib.utils.statusbar.StatusBarUtils
import com.example.smart.R
import com.example.smart.base.ui.activity.BaseActivity
import com.example.smart.databinding.ActivityVaccinesPointBinding
import com.example.smart.utils.DisplayUtils

class VaccinesPointActivity : BaseActivity<ActivityVaccinesPointBinding>() {
    private var flag1 = SpUtils.getBoolean("vaccines1", false)
    private var flag2 = SpUtils.getBoolean("vaccines2", false)

    override fun layoutID() = R.layout.activity_vaccines_point

    override fun initView() {
        StatusBarUtils.setStateAndNavigationBar(this@VaccinesPointActivity,
            statusBarColor = com.example.lib.R.color.translate)
        binding.Radio1.isChecked = true
    }

    override fun onResume() {
        super.onResume()
        flag1 = SpUtils.getBoolean("vaccines1", false)
        flag2 = SpUtils.getBoolean("vaccines2", false)
        binding.Gz.setImageResource(if (flag1) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
        binding.GzBack.setBackgroundResource(if (flag1) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)

        binding.Gz2.setImageResource(if (flag2) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
        binding.GzBack2.setBackgroundResource(if (flag2) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
    }

    override fun initListener() {
        binding.Search.setOnDoubleClickListener {
            DisplayUtils.toSearch(this@VaccinesPointActivity)
        }

        binding.GzBack.setOnDoubleClickListener {
            flag1 = !flag1
            binding.Gz.setImageResource(if (flag1) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack.setBackgroundResource(if (flag1) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines1", flag1)
        }

        binding.Gz.setOnDoubleClickListener {
            flag1 = !flag1
            binding.Gz.setImageResource(if (flag1) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack.setBackgroundResource(if (flag1) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines1", flag1)
        }

        binding.GzBack2.setOnDoubleClickListener {
            flag2 = !flag2
            binding.Gz2.setImageResource(if (flag2) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack2.setBackgroundResource(if (flag2) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines2", flag2)
        }

        binding.Gz2.setOnDoubleClickListener {
            flag2 = !flag2
            binding.Gz2.setImageResource(if (flag2) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack2.setBackgroundResource(if (flag2) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines2", flag2)
        }

        binding.Rel1.setOnDoubleClickListener {
            DisplayUtils.toVaccinesPointDetails(this@VaccinesPointActivity, 1)
        }

        binding.Rel2.setOnDoubleClickListener {
            DisplayUtils.toVaccinesPointDetails(this@VaccinesPointActivity, 2)
        }
    }

    override fun isNeedAllTab(): Boolean {
        return true
    }

}